CSharpTest.Net
AddRange(IEnumerable<KeyValuePair<TKey,TValue>>,Boolean) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class > AddRange Method : AddRange(IEnumerable<KeyValuePair<TKey,TValue>>,Boolean) Method

unorderedItems
The items to insert
allowUpdates
True to overwrite any existing records

Glossary Item Box

Presorts the provided enumeration in batches and then performs an optimized insert on the resulting set(s).

Syntax

Visual Basic (Declaration) 
Public Overloads Function AddRange( _
   ByVal unorderedItems As IEnumerable(Of KeyValuePair(Of TKey,TValue)), _
   ByVal allowUpdates As Boolean _
) As Integer

Parameters

unorderedItems
The items to insert
allowUpdates
True to overwrite any existing records

Return Value

The total number of records inserted or updated

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C#Copy Code
Stopwatch sw = Stopwatch.StartNew();
var options = Options.Clone();
using (TempFile temp = new TempFile())
{
    //using (BPlusTree<int, string> data = Create(Options))
    using (BPlusTree<int, string> data = Create(options))
    {
        const bool bulk = true;
        Insert(data, CreateRandom(1000, 3000), bulk, false);

        data.EnableCount();
        Assert.AreEqual(1000, data.Count);

        Insert(data, CreateCount(data.Last().Key + 1, 1, 1000), bulk, true);
        Assert.AreEqual(2000, data.Count);

        Insert(data, CreateCount(data.Last().Key + 10001, -1, 1000), bulk, false);
        Assert.AreEqual(3000, data.Count);

        int lastKey = data.Last().Key;
        data.AddRange(CreateCount(1, 2, lastKey / 2), true);
    }
    temp.Dispose();
}
Trace.WriteLine("Inserted in " + sw.Elapsed);
VB.NETCopy Code
Dim sw As Stopwatch = Stopwatch.StartNew()
Dim options As var = Options.Clone()
Using temp As New TempFile()
    'using (BPlusTree<int, string> data = Create(Options))
    Using data As BPlusTree(Of Integer, String) = Create(options)
        Const  bulk As Boolean = True
        Insert(data, CreateRandom(1000, 3000), bulk, False)

        data.EnableCount()
        Assert.AreEqual(1000, data.Count)

        Insert(data, CreateCount(data.Last().Key + 1, 1, 1000), bulk, True)
        Assert.AreEqual(2000, data.Count)

        Insert(data, CreateCount(data.Last().Key + 10001, -1, 1000), bulk, False)
        Assert.AreEqual(3000, data.Count)

        Dim lastKey As Integer = data.Last().Key
        data.AddRange(CreateCount(1, 2, lastKey / 2), True)
    End Using
    temp.Dispose()
End Using
Trace.WriteLine("Inserted in " + sw.Elapsed)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys